#include "stdio.h"
main()
{
	int n,s1,s2;
	int a[21],b[21];
	int i,j,p,q;

	scanf("%d",&n);
	while (n!=0)
	{	
		s1=0;s2=0;
		for (i=1;i<=n;i++) scanf("%d",&a[i]);
		for (i=1;i<=n;i++) scanf("%d",&b[i]);
		
		for (i=1;i<=n;i++)
		{
			p=a[i];q=b[i];
			if (( (p==1)&&(q==2) )||( (p==2)&&(q==1) ))
			{
				if (p==1) s1+=6;
				else s2+=6;	
			}
			else if ( ((p-q)==1)||((q-p)==1) )
			{
				j=p+q;
				if (p>q) s2+=j;
				else s1+=j;	
			}
			else if (p==q)
			{
				
			}
			else
			{
				if (p>q) s1+=p;
				else s2+=q;	
			}
		}
		printf("A has %d points. B has %d points.\n",s1,s2);
		scanf("%d",&n);
		if (n!=0) printf("\n");
	}
	
}
